<template>
    <example :template-code="templateString">
        <template #describe>
            <t :id="`${$t('基础示例')}`">{{ $t('基础示例') }}</t>
            <li>
                <span class="s-code">v-model</span>所绑定的值是个数组，初始值支持传入由行数据的
                <span class="s-code">rowKey</span>组成的数组，也支持传入由<span style="color:#000;font-weight: 600;"> 行数据row </span>组成的数组
            </li>
            <li>
                <span class="s-code">rowKey</span>用于指定数据行的唯一键，组件内部默认取数据行内的<span class="s-code">"id"</span>，如果数据行内不存在
                <span class="s-code">"id"</span>，那么你必须配置<span class="s-code">rowKey</span>
            </li>
            <li>
                当选择数据行后，<span class="s-code">v-model</span>的值将会变成由<span style="color:#000;font-weight: 600;">行数据row</span>组成的数组
            </li>
        </template>
        <div style="width: 300px;">
            <sib-item v-model="value" :props="props" @change="change"></sib-item>
        </div>
        <p style="color: #666;">当前选择的是：{{ value && value.length ? value : '--' }}</p>
    </example>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value = ref(['5']);
        const props = reactive({
            type: 'table',
            rowKey: 'rowId',
            tableColumn: [
                { label: '姓名', code: 'name' },
                { label: '人员编码', code: 'code' },
            ],
            tableData: [
                { name: '张三', code: '001', rowId: '1' },
                { name: '李四', code: '002', rowId: '2' },
                { name: '王五', code: '003', rowId: '3' },
                { name: '奔跑的提款机', code: '666', rowId: '4' },
                { name: '前端爱好者', code: '004', rowId: '5' },
                { name: '菜鸟', code: '005', rowId: '6' },
                { name: '旗鼓相当的对手', code: '006', rowId: '7' },
            ],
        });
        const change = (data) => {
            console.log('data: ', data);
        };

        return {
            props,
            value,
            change,
            templateString: `<template>
    <sib-item v-model="value" :props="props" @change="change"></sib-item>
    <p>当前选择的是：{{ value && value.length ? value : '--' }}</p>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value = ref(['5']);
        const props = reactive({
            type: 'table',
            rowKey: 'rowId',
            tableColumn: [
                { label: '姓名', code: 'name' },
                { label: '人员编码', code: 'code' },
            ],
            tableData: [
                { name: '张三', code: '001', rowId: '1' },
                { name: '李四', code: '002', rowId: '2' },
                { name: '王五', code: '003', rowId: '3' },
                { name: '奔跑的提款机', code: '666', rowId: '4' },
                { name: '前端爱好者', code: '004', rowId: '5' },
                { name: '菜鸟', code: '005', rowId: '6' },
                { name: '旗鼓相当的对手', code: '006', rowId: '7' },
            ],
        });
        const change = (data) => {
            console.log('data: ', data);
        };

        return { props, value, change };
    },
};
<\/script>`,
        };
    },
};
</script>
